/*	@brief	:	CThread Execption
*	@author	: 	yangcancheng
*	@date	:	20090804
*/
#ifndef _CTHREAD_EXCEPTION_H_
#define _CTHREAD_EXCEPTION_H_ 

#include <exception>
#include <string>

using namespace std;

namespace CThread
{
	class Exception : public std::exception 
	{
	public:
		Exception() {}

		Exception(const string& sMsg) : m_sMsg(sMsg) {}

		virtual ~Exception() throw() {}
		
		virtual const char* what() const throw() 
		{
			if (m_sMsg.empty())
			{
				return "Default Exception.";
			} 
			else 
			{
				return m_sMsg.c_str();
			}
		}

		protected:
			std::string m_sMsg;
	};
	
	class TimedOutException : public Exception 
	{
	public:
		TimedOutException():Exception("TimedOutException"){};
		TimedOutException(const std::string& sMsg) : Exception(sMsg) {}
	};

	class TooManyPendingTasksException : public Exception 
	{
	public:
		TooManyPendingTasksException():Exception("TooManyPendingTasksException"){};
		TooManyPendingTasksException(const std::string& sMsg) : Exception(sMsg) {}
	};

	class SystemResourceException : public Exception 
	{
	public:
		SystemResourceException() {}

		SystemResourceException(const std::string& sMsg) : Exception(sMsg) {}
	};

	class WorkThreadInitException :public Exception{};
	
	class NoSuchTaskException : public Exception {};

	class UncancellableTaskException : public Exception {};

	class InvalidArgumentException : public Exception {};

	class IllegalStateException : public Exception {};
	
	class InitializationException : public Exception{};
	
	class SynchronizationException : public Exception{};
};

#endif // #ifndef _CTHREAD_EXCEPTION_H_
